<!-- 
         该方法已经过时，请使用dialogTableSelect.tag
	creator:lxh
	data:20160321
	name:弹出页面包含jdgrid
 -->
<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ attribute name="id" type="java.lang.String" required="true" description="编号"%>
<%@ attribute name="name" type="java.lang.String" required="true" description="隐藏域名称（ID）"%>
<%@ attribute name="value" type="java.lang.String" required="true" description="隐藏域值（ID）"%>
<%@ attribute name="codeName" type="java.lang.String" required="false" description="隐藏域名称（codeName）"%>
<%@ attribute name="codeValue" type="java.lang.String" required="false" description="隐藏域名称（codeValue）"%>
<%@ attribute name="labelName" type="java.lang.String" required="true" description="输入框名称（Name）"%>
<%@ attribute name="labelValue" type="java.lang.String" required="true" description="输入框值（Name）"%>
<%@ attribute name="title" type="java.lang.String" required="true" description="选择框标题"%>
<%@ attribute name="url" type="java.lang.String" required="true" description="树结构数据地址"%>
<%@ attribute name="checked" type="java.lang.Boolean" required="false" description="是否显示复选框，如果不需要返回父节点，请设置notAllowSelectParent为true"%>
<%@ attribute name="extId" type="java.lang.String" required="false" description="排除掉的编号（不能选择的编号）"%>
<%@ attribute name="isAll" type="java.lang.Boolean" required="false" description="是否列出全部数据，设置true则不进行数据权限过滤（目前仅对Office有效）"%>
<%@ attribute name="notAllowSelectRoot" type="java.lang.Boolean" required="false" description="不允许选择根节点"%>
<%@ attribute name="notAllowSelectParent" type="java.lang.Boolean" required="false" description="不允许选择父节点"%>
<%@ attribute name="module" type="java.lang.String" required="false" description="过滤栏目模型（只显示指定模型，仅针对CMS的Category树）"%>
<%@ attribute name="selectScopeModule" type="java.lang.Boolean" required="false" description="选择范围内的模型（控制不能选择公共模型，不能选择本栏目外的模型）（仅针对CMS的Category树）"%>
<%@ attribute name="allowClear" type="java.lang.Boolean" required="false" description="是否允许清除"%>
<%@ attribute name="allowInput" type="java.lang.Boolean" required="false" description="文本框可填写"%>
<%@ attribute name="cssClass" type="java.lang.String" required="false" description="css样式"%>
<%@ attribute name="cssStyle" type="java.lang.String" required="false" description="css样式"%>
<%@ attribute name="smallBtn" type="java.lang.Boolean" required="false" description="缩小按钮显示"%>
<%@ attribute name="hideBtn" type="java.lang.Boolean" required="false" description="是否显示按钮"%>
<%@ attribute name="disabled" type="java.lang.String" required="false" description="是否限制选择，如果限制，设置为disabled"%>
<%@ attribute name="dataMsgRequired" type="java.lang.String" required="false" description=""%>
<%@ attribute name="width" type="java.lang.String" required="true" description="窗口宽度"%>
<%@ attribute name="height" type="java.lang.String" required="true" description="窗口高度"%>
<%@ attribute name="isSaveNo" type="java.lang.Boolean" required="false" description="是否保存员工no  默认不保存"%>


<!-- add for lgx 20160606 弹出框点击确定后执行的js函数执行函数（父页面传递过来），通过该函数可以实现操作父页面（例如根据子页面的值异步刷新父页面） -->
<%@ attribute name="completeJs" type="java.lang.String" required="false" description="弹出框后点击确定后执行的js函数"%>
<!-- add for lgx 20160606 弹出框点击之前触发函数-->
<%@ attribute name="beforeJs" type="java.lang.String" required="false" description="弹出框点击时候触发js函数"%>

<div class="input-append">
 	<input type="hidden" id="${id}Url" value="${url}"/> 
	<input id="${id}Id" name="${name}" class="${cssClass}" type="hidden" value="${value}"/>
	
	<c:choose>
		<c:when test="${isSaveNo==true}">
			<input id="${id}codeName" name="${codeName}" class="${cssClass}" type="hidden" value="${codeValue}"/>
		</c:when>
	</c:choose>
	<input id="${id}Name" name="${labelName}" ${allowInput?'':'readonly="readonly"'} type="text" value="${labelValue}" data-msg-required="${dataMsgRequired}"
		class="${cssClass}" style="${cssStyle}"/><a id="${id}Button" href="javascript:" class="btn ${disabled} ${hideBtn ? 'hide' : ''}" style="${smallBtn?'padding:4px 2px;':''}"><i class="icon-search"></i></a>
</div>
<script type="text/javascript">
	$("#${id}Button, #${id}Name").click(function(){
		// 是否限制选择，如果限制，设置为disabled
		if ($("#${id}Button").hasClass("disabled")){
			return true;
		}
		
		//点击之后触发函数，可以预先初始化 父页面或者子页面 
		${beforeJs}
		
		var isSaveNo=false;
		if(${isSaveNo==""}){isSaveNo=true;};
		
		var url = $("#${id}Url").val();
		// 正常打开	
		top.$.jBox.open("iframe:"+url, "选择${title}", ${width}, ${height}, {
			persistent : true,
			top:"0%",
			ajaxData:{selectIds: $("#${id}Id").val()},buttons:{"确定":"ok", ${allowClear?"\"清除\":\"clear\", ":""}"关闭":true}, submit:function(v, h, f){
				if (v=="ok"){
					
					var ids = [], names = [], nodes = [],nos=[];
					var spans=h.find("iframe").contents().find(".selectlabel>span");
					
					if (spans.length == 0){
						top.$.jBox.tip("请选择用户名。");
						return false;
					}
					
					for(var i=0;i<spans.length;i++){
						ids.push(spans.find("input[name=id]").val());
						names.push(spans.find("input[name=name]").val());
						nos.push(spans.find("input[name=no]").val());
					}
					
					$("#${id}Id").val(ids.join(",").replace(/u_/ig,""));
					$("#${id}Name").val(names.join(","));
					isSaveNo?$("#${id}codeName").val(nos.join(",")):"";
					//执行父页面函数
					${completeJs}
					
				}//<c:if test="${allowClear}">
				else if (v=="clear"){
					$("#${id}Id").val("");
					$("#${id}Name").val("");
					isSaveNo?$("#${id}codeName").val(""):"";
                }//</c:if>
				/* if(typeof ${id}TreeselectCallBack == 'function'){
					${id}TreeselectCallBack(v, h, f);
				} */
			}, loaded:function(h){
				$(".jbox-content", top.document).css("overflow-y","hidden");
			}
		});
	});
</script>
